﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using CUWo.Common.Entities.WoInterface.HttpJsonResult;

/**
 * 创建时间：2014/11/20 12:37:19
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace CUWo.Common.Converter
{
    public class NewContentTemplateConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return System.Windows.Visibility.Collapsed;

            try
            {
                var items = value as ObservableCollection<PicInf>;
                if(items != null && items.Count >0)
                {
                    if(!string.IsNullOrWhiteSpace(items[0].Path))
                    {
                        return Visibility.Visible;
                    }
                }
            }
            catch(Exception err)
            {
                LogHelper.LogError(err.ToString(), this.GetType(), MethodBase.GetCurrentMethod());
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }
}
